
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>变量提升 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Landen">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="作用域.html" />
    
    
    <link rel="prev" href="函数.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../01html/html简介.html">
            
                <a href="../01html/html简介.html">
            
                    
                    HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../01html/01html.html">
            
                <a href="../01html/01html.html">
            
                    
                    a链接、图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../01html/02html.html">
            
                <a href="../01html/02html.html">
            
                    
                    列表、表格、表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../01html/h5新增.html">
            
                <a href="../01html/h5新增.html">
            
                    
                    h5新增
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../02css/css简介.html">
            
                <a href="../02css/css简介.html">
            
                    
                    CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../02css/居中、省略、清浮.html">
            
                <a href="../02css/居中、省略、清浮.html">
            
                    
                    居中、省略、清浮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../02css/浮动和定位.html">
            
                <a href="../02css/浮动和定位.html">
            
                    
                    浮动和定位
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../02css/变换、过渡、动画.html">
            
                <a href="../02css/变换、过渡、动画.html">
            
                    
                    变换、过渡、动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../02css/sass和rem.html">
            
                <a href="../02css/sass和rem.html">
            
                    
                    sass和rem
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../02css/flex、media、栅格化.html">
            
                <a href="../02css/flex、media、栅格化.html">
            
                    
                    flex、media、栅格化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="js简介.html">
            
                <a href="js简介.html">
            
                    
                    JavaScript
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="数据类型.html">
            
                <a href="数据类型.html">
            
                    
                    数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="字符串.html">
            
                <a href="字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="数组.html">
            
                <a href="数组.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="回流和重绘.html">
            
                <a href="回流和重绘.html">
            
                    
                    回流和重绘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="浏览器的渲染过程.html">
            
                <a href="浏览器的渲染过程.html">
            
                    
                    浏览器的渲染过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="十大排序算法.html">
            
                <a href="十大排序算法.html">
            
                    
                    十大排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="对象的构建.html">
            
                <a href="对象的构建.html">
            
                    
                    对象的构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="this.html">
            
                <a href="this.html">
            
                    
                    this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="bind&call&apply.html">
            
                <a href="bind&call&apply.html">
            
                    
                    bind&call&apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.11" data-path="变量提升.html">
            
                <a href="变量提升.html">
            
                    
                    变量提升
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="作用域.html">
            
                <a href="作用域.html">
            
                    
                    作用域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="对象.html">
            
                <a href="对象.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path="存储.html">
            
                <a href="存储.html">
            
                    
                    存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.15" data-path="事件.html">
            
                <a href="事件.html">
            
                    
                    事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.16" data-path="图片预览.html">
            
                <a href="图片预览.html">
            
                    
                    图片预览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.17" data-path="防抖节流.html">
            
                <a href="防抖节流.html">
            
                    
                    防抖节流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.18" data-path="同步异步.html">
            
                <a href="同步异步.html">
            
                    
                    同步异步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.19" data-path="babel入门.html">
            
                <a href="babel入门.html">
            
                    
                    babel入门
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.20" data-path="nvm.html">
            
                <a href="nvm.html">
            
                    
                    nvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.21" data-path="ES6.html">
            
                <a href="ES6.html">
            
                    
                    ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.22" data-path="ES6-ES11.html">
            
                <a href="ES6-ES11.html">
            
                    
                    ES6-ES11
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >变量提升</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x53D8;&#x91CF;&#x63D0;&#x5347;">&#x53D8;&#x91CF;&#x63D0;&#x5347;</h2>
<ul>
<li>&#x51FD;&#x6570;&#x5728;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x65F6;&#xFF0C;&#x4F1A;&#x5148;&#x8FDB;&#x884C;&#x9884;&#x89E3;&#x6790;&#xFF0C;&#x5BF9;&#x4F7F;&#x7528;var&#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;&#x63D0;&#x5347;&#x81F3;&#x4F5C;&#x7528;&#x57DF;&#x9876;&#x90E8;&#x8FDB;&#x884C;&#x58F0;&#x660E;&#xFF0C;&#x5BF9; &#x51FD;&#x6570; &#x4E5F;&#x540C;&#x6837;&#x8FDB;&#x884C;&#x63D0;&#x5347;(&#x58F0;&#x660E;&#x5F0F;&#x51FD;&#x6570;&#x63D0;&#x5347;&#x4E3A;<strong>&#x5B8C;&#x5168;&#x63D0;&#x5347;</strong>&#xFF0C;&#x8868;&#x8FBE;&#x5F0F;&#x5219;&#x4EC5;&#x63D0;&#x5347;&#x6807;&#x8BC6;&#x7B26;)</li>
<li>&#x672A;&#x4F7F;&#x7528;&#x53D8;&#x91CF;&#x58F0;&#x660E;&#x7B26;&#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x4F1A;&#x9ED8;&#x8BA4;&#x63D0;&#x5347;&#x81F3;&#x5168;&#x5C40;&#x4F5C;&#x7528;&#x57DF;&#x4E0A;&#xFF0C;&#x6210;&#x4E3A;&#x5168;&#x5C40;&#x53D8;&#x91CF;</li>
<li>&#x4F7F;&#x7528; var &#x8FDB;&#x884C;&#x53D8;&#x91CF;&#x58F0;&#x660E;&#x65F6;&#xFF0C;&#x4F1A;&#x5FFD;&#x7565;&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#xFF0C;&#x63D0;&#x5347;&#x81F3;&#x5F53;&#x524D;&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;&#x7684;&#x5916;&#x90E8;&#x4F5C;&#x7528;&#x57DF;</li>
</ul>
<h2 id="&#x51FD;&#x6570;&#x63D0;&#x5347;">&#x51FD;&#x6570;&#x63D0;&#x5347;</h2>
<ol>
<li><p>&#x58F0;&#x660E;&#x5F0F;&#x51FD;&#x6570;</p>
</li>
<li><p>&#x5728;&#x9884;&#x89E3;&#x6790;&#x9636;&#x6BB5;&#xFF0C;&#x4F1A;&#x5B8C;&#x6574;&#x63D0;&#x5347;&#x81F3;&#x4F5C;&#x7528;&#x57DF;&#x9876;&#x90E8;</p>
</li>
<li><p>&#x58F0;&#x660E;&#x5F0F;&#x51FD;&#x6570;&#x4F18;&#x5148;&#x7EA7;&#x66F4;&#x9AD8;&#xFF0C;&#x5982;&#x679C;&#x51FA;&#x73B0;&#x540C;&#x540D;&#x53D8;&#x91CF;&#xFF0C;&#x5728;&#x540C;&#x540D;&#x53D8;&#x91CF;&#x5B8C;&#x6210;&#x8D4B;&#x503C;&#x524D;&#xFF0C;&#x51FD;&#x6570;&#x4E0D;&#x4F1A;&#x88AB;&#x8986;&#x76D6;</p>
</li>
<li><p>&#x8868;&#x8FBE;&#x5F0F;&#x51FD;&#x6570;</p>
</li>
<li><p>&#x4E0E;&#x666E;&#x901A;&#x7684;&#x53D8;&#x91CF;&#x63D0;&#x5347;&#x4E00;&#x81F4;&#xFF0C;&#x4EC5;&#x63D0;&#x5347;&#x6807;&#x8BC6;&#x7B26;&#x58F0;&#x660E;&#xFF0C;&#x5F85;&#x51FD;&#x6570;&#x6267;&#x884C;&#x81F3;&#x8D4B;&#x503C;&#x8BED;&#x53E5;&#x65F6;&#xFF0C;&#x624D;&#x8FDB;&#x884C;&#x8D4B;&#x503C;&#x5B9A;&#x4E49;</p>
</li>
</ol>
<h2 id="json-&#x5185;&#x7F6E;&#x5BF9;&#x8C61;">JSON &#x5185;&#x7F6E;&#x5BF9;&#x8C61;</h2>
<ul>
<li>&#x50A8;&#x5B58; &#x5E94;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x4F1A;&#x5F3A;&#x5236;&#x8F6C;&#x6362;&#x4E3A; &#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x5BF9;&#x8C61;&#x4F1A;&#x53D8;&#x6210;&quot;[object Object]&quot;,&#x6240;&#x4EE5;&#x9700;&#x8981;&#x5148;&#x5C06;&#x5BF9;&#x8C61;&#x901A;&#x8FC7; JSON.stringify &#x8F6C;&#x6210;&#x5B57;&#x7B26;&#x4E32;&#x5F62;&#x5F0F;&#x518D;&#x8FDB;&#x884C;&#x5B58;&#x50A8;&#xFF1B;&#x83B7;&#x53D6;&#x6570;&#x636E;&#x540E;&#x901A;&#x8FC7; JSON.parse &#x8FDB;&#x884C;&#x89E3;&#x6790;</li>
</ul>
<h2 id="&#x503C;&#x5F15;&#x7528;">&#x503C;&#x5F15;&#x7528;</h2>
<ul>
<li>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x95F4;,&#x4F7F;&#x7528; = &#x8D4B;&#x503C;&#x65F6;,&#x4F1A;&#x514B;&#x9686;&#x4E00;&#x4EFD;&#x539F;&#x6570;&#x636E; &#x7ED9;&#x5230;&#x65B0;&#x53D8;&#x91CF;,&#x6240;&#x4EE5; a b &#x95F4;&#x4E92;&#x4E0D;&#x5F71;&#x54CD;</li>
<li>&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x95F4;,&#x4F7F;&#x7528; = &#x8D4B;&#x503C;&#x65F6;,&#x4EC5;&#x62F7;&#x8D1D;&#x5176; &#x5806;&#x5185;&#x5B58;&#x5730;&#x5740; &#x7684;&#x5F15;&#x7528;;&#x6240;&#x4EE5;&#x64CD;&#x4F5C; obj2 &#x65F6;,obj1&#x4E5F;&#x968F;&#x4E4B;&#x6539;&#x53D8;</li>
</ul>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> data = {
    num: <span class="hljs-number">100</span>,
};
<span class="hljs-keyword">let</span> str = <span class="hljs-string">&quot;bluej&quot;</span>;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">test</span>(<span class="hljs-params">_str, _arg</span>) </span>{
    <span class="hljs-comment">// &#x4F20;&#x9012; &#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x540C;&#x6837;&#x4F1A;&#x514B;&#x9686;&#x4E00;&#x4EFD;&#x6570;&#x636E;&#x7ED9;&#x5F62;&#x53C2;&#xFF1B;</span>
    <span class="hljs-comment">// &#x800C;&#x4F20;&#x9012; &#x5F15;&#x7528;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x540C;&#x6837;&#x4EC5;&#x514B;&#x9686;&#x5185;&#x5B58;&#x5730;&#x5740;&#x5F15;&#x7528;&#xFF1B;</span>
    <span class="hljs-comment">// _str = arguments[0] = &quot;bluej&quot;;</span>
    <span class="hljs-comment">// _arg = arguments[1] = data;</span>
    _str = <span class="hljs-string">&quot;1111&quot;</span>;
    _arg.num = <span class="hljs-number">888</span>;
}
test(str, data);
<span class="hljs-built_in">console</span>.log(str, data);
</code></pre>

                                
                                </section>
                            
                        </div>
                    </div>
                
            </div>

            
                
                <a href="函数.html" class="navigation navigation-prev " aria-label="Previous page: 函数">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="作用域.html" class="navigation navigation-next " aria-label="Next page: 作用域">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"变量提升","level":"1.4.11","depth":2,"next":{"title":"作用域","level":"1.4.12","depth":2,"path":"md/03js/作用域.md","ref":"./md/03js/作用域.md","articles":[]},"previous":{"title":"函数","level":"1.4.10","depth":2,"path":"md/03js/函数.md","ref":"./md/03js/函数.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","-sharing","toggle-chapters","image-captions","-anchor-navigation","-anchor-navigation-ex"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"image-captions":{"attributes":{"style":"left: 50%;position: relative;transform: translateX(-50%);"},"caption":"图 _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_","align":"center","variable_name":"_pictures"},"fontsettings":{"theme":"night","family":"sans","size":2},"toggle-chapters":{},"highlight":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Landen","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[]},"gitbook":"3.x.x"},"file":{"path":"md/03js/变量提升.md","mtime":"2020-07-27T15:35:40.684Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-17T10:41:18.504Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

